﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master/b.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="assets/css/login.min.css" rel="stylesheet">
    <style type="text/css">
        body, body.full-height-layout #page-wrapper, body.full-height-layout #wrapper, html {
            height: auto;
        }

        html {
            /*background: url(assets/img/bg/login_bg.jpg) no-repeat center center;*/
            /*background-size: 100% 100%;
            height: 100%;*/
            background-color:#66C2BF;
        }
        .signinpanel {
            width: 760px;
            margin: 12% auto 0;
        }
        .signinpanel form {
            /*background: url(assets/img/bg/login_box_bg.png);*/
            border: 0;
            width: auto;  
            height: auto;  
            max-width: 120%;  
            max-height: 100%;     
           
        }

            .signinpanel form h4 span {
                display: inline-block;
                color: #fff;
                margin-left: 5px;
                font-size: 15px;
            }

        .signin-info {
            border: 0;
            width:70%;
        }

       .signin-info-img{  
            width: auto;  
            height: auto;  
            max-width: 130%;  
            max-height: 100%;     
        }  

        .signup-footer {
            position: absolute;
            text-align: center;
            left: 8%;
            bottom: 0;
            width: 84%;
            color: #fff;
            font-family: "Microsoft YaHei", SimHei;
        }

        .gray-bg {
            background-color: transparent;
        }

        .form-control {
            background: #fff;
            border: 0;
            border-radius: 3px;
        }

        .btn-login {
            /*background: url(assets/img/bg/login_btn_bg.png) no-repeat center;*/
            background-color:#66c2bf;
            background-size: cover;
            font-size: 18px;
            padding: 4px;
            /*color: #231916;*/
            color: rgba(14, 14, 14, 0.66);
            letter-spacing: 2px;
            border: 0;
        }

        .signinpanel .logopanel h1,
        .signinpanel h4.submitTitle {
            color: #bbb;
            animation: changeColor 6s alternate infinite ease;
            -webkit-animation: changeColor 6s alternate infinite ease;
            -moz-animation: changeColor 6s alternate infinite ease;
            -o-animation: changeColor 6s alternate infinite ease;
        }

        .chat-element, .chat-element .media, .m-t, .feed-element, .feed-element .media, .social-comment {
    margin-top: 54px;
}

        @keyframes changeColor {
            0% {
                color: #bbb;
                text-shadow: 0 0 0 #bbb;
            }

            100% {
                color: #fff;
                text-shadow: 0 0 8px #fff;
            }
        }
        /* Firefox */
        @-moz-keyframes changeColor {
            0% {
                color: #bbb;
                text-shadow: 0 0 0 #bbb;
            }

            100% {
                color: #fff;
                text-shadow: 0 0 8px #fff;
            }
        }
        /* Safari 和 Chrome */
        @-webkit-keyframes changeColor {
            0% {
                color: #bbb;
                text-shadow: 0 0 0 #bbb;
            }

            100% {
                color: #fff;
                text-shadow: 0 0 8px #fff;
            }
        }
        /* Opera */
        @-o-keyframes changeColor {
            0% {
                color: #bbb;
                text-shadow: 0 0 0 #bbb;
            }

            100% {
                color: #fff;
                text-shadow: 0 0 8px #fff;
            }
        }
      
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-7">
                <div class="signin-info">
                    <img class="signin-info-img" src="assets/img/bg/logo_font.png" />
                  <%--  <div class="logopanel m-b">
                        <h1>NM+</h1>
                    </div>
                    <div class="m-b"></div>
                    <h4 class="submitTitle">欢迎使用NM+后台系统</h4>
                    <strong class="hide">还没有账号？ <a href="#">立即注册&raquo;</a></strong>--%>
                </div>
            </div>
            <div class="col-sm-5">
                <form id="checkFrom" method="post" class="m-t" role="form" autocomplete="off">
                  <%--  <img class="signin-info-img" src="assets/img/bg/login_box_bg.png" />--%>
                    <h4 class="no-margins">
                        <%--<img class="title_icon" src="favicon.ico" />--%>
                        <span>登录账号</span>
                    </h4>
                    <div class="form-group">
                        <input type="text" id="loginaccount" class="form-control"
                            placeholder="用户名" autocomplete="off" value="">
                    </div>
                    <div class="form-group">
                        <input type="password" id="password" class="form-control"
                            placeholder="密码" autocomplete="off" value="">
                    </div>
                    <button type="button" class="btn btn-block m-b btn-login">登录</button>
                </form>
            </div>
        </div>
        <div class="signup-footer">&copy; 2016-2017 All Rights Reserved. NM</div>
    </div>
    <div id="ssologin" class="hide">
        <iframe id="sso" src="" style="display: none"></iframe>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="server">
    <script src="assets/js/plugins/url/url.js?version=2.5.0"></script>
    <script type="text/javascript">
        $(function () {

            //检测是否启用SSO
            var SSO_Enable = <%=System.Web.Configuration.WebConfigurationManager.AppSettings["SSO_Enable"]%>;
            //如果没有启用
            if (SSO_Enable == undefined || !SSO_Enable) {

            }
            //如果启用
            else {
                var ssoUrl = "<%=System.Web.Configuration.WebConfigurationManager.AppSettings["CookieHost"]%>";
                var appkey = "<%=System.Web.Configuration.WebConfigurationManager.AppSettings["appkey"]%>";
            var appSecret = "<%=System.Web.Configuration.WebConfigurationManager.AppSettings["appSecret"]%>";
            var ReturnUrl = "<%=System.Web.Configuration.WebConfigurationManager.AppSettings["ReturnUrl"]%>";
            var LoginUrl = "<%=System.Web.Configuration.WebConfigurationManager.AppSettings["LoginUrl"]%>";
            //如果有CheckOnline,则不再加载sso
            if ($.url("?CheckOnline") == "true") {
                console.log('已检测未登录,走正常登录流程');
                //如果是申请注销
                if ($.url("?RemoveToken") == "true" &&
                    $.url("?userid") != undefined &&
                    $.url("?token") != undefined) {
                    console.log('进入注销流程');
                    //加载SSO页面清除cookie
                    var iframeSrc = ssoUrl +
                        "?appkey=" + appkey +
                        "&appSecret=" + appSecret +
                        "&userId=" + $.url("?userid") +
                        "&LoginUrl=" + LoginUrl +
                        "&ReturnUrl=" + ReturnUrl;
                    iframeSrc = encodeURI(iframeSrc);
                    $("#sso").attr("src", iframeSrc);
                    //调用api清除sso上的用户

                    Y.API2('Login', 'OutLogin',
                        {
                            "UserId": $.url("?userid"),
                            "Token": $.url("?token")
                        }, function (data) {
                            if (data.Success == false) {
                                swal(data.Message, '', 'error');
                            } else {
                                top.location.href = "login.aspx?CheckOnline=true";
                            }
                        });
                }
            } else {
                //先加载SSO检测登录页面
                var iframeSrc = ssoUrl +
                    "?appkey=" + appkey +
                    "&appSecret=" + appSecret +
                    "&LoginUrl=" + LoginUrl +
                    "&ReturnUrl=" + ReturnUrl;
                iframeSrc = encodeURI(iframeSrc);
                $("#sso").attr("src", iframeSrc);
            }
            }
            $(".btn-login").click(function () {
                var loginaccount = $('#loginaccount').val();
                var password = $('#password').val();
                if (Y.checkNull(loginaccount.trim())) {
                    layer.tips('请输入用户名', '#loginaccount');
                    return false;
                }
                if (Y.checkNull(password.trim())) {
                    layer.tips('请输入密码', '#password');
                    return false;
                }
                Y.API2("Login",
                    "Login",
                    {
                        "UserName": loginaccount,
                        "PassWord": md5(password),
                        "PassWord2": password,
                        "ForceLogin": ($.url("?ForceLogin") == undefined || $.url("?ForceLogin") == null) ? 0 : 1
                    }, function (data) {
                        if (data.Success == false) {
                            layer.alert(data.Message);
                        } else {
                            sessionStorage.setItem('login-info', JSON.stringify(data));
                            //判断是否启用sso
                            //如果未启用
                            if (SSO_Enable == undefined || !SSO_Enable) {
                                top.location.href = "index.aspx";
                            }
                            //如果已启用
                            else
                            {
                                //加载返回的sso信息
                                var onlineInfo = data.OnlineInfo;
                                if (!Y.checkNull(onlineInfo) && !Y.checkNull(onlineInfo.Token) &&
                                    !Y.checkNull(onlineInfo.UserID) && !Y.checkNull(onlineInfo.UserName)) {

                                    var iframeSrc = ssoUrl +
                                        "?appkey=" + appkey +
                                        "&appSecret=" + appSecret +
                                        "&LoginUrl=" + LoginUrl +
                                        "&ReturnUrl=" + ReturnUrl +
                                        "&Token=" + onlineInfo.Token +
                                        "&UserName=" + onlineInfo.UserName +
                                        "&UserID=" + onlineInfo.UserID;
                                    iframeSrc = encodeURI(iframeSrc);
                                    $("#sso").attr("src", iframeSrc);
                                }
                                     }
                            }


                    });
            });
            $(document).keyup(function (event) {
                //获取当前按键的键值   
                //jQuery的event对象上有一个which的属性可以获得键盘按键的键值   
                var keycode = event.which;
                //处理回车的情况   
                if (keycode == 13) {
                    $(".btn-login").click();
                }
            });
        });
    </script>
</asp:Content>
